package com.memexue.order.controller;

import com.memexue.order.message.StreamClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class SendMessageController {
    @Autowired
    private StreamClient streamClient;

    /**
     * 发送stream消息
     */
    @GetMapping("sendStreamMsg")
    public void sendStreamMsg(){
        String msg = "now " + System.currentTimeMillis();
        log.info("发送消息={}", msg);
        streamClient.output().send(MessageBuilder.withPayload(msg).build());
    }
}
